package com.itheima.userdemo.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 根据用户名判断是否存在
 */
@WebServlet("/selectUserServlet")
public class SelectUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 假设前端是通过URL传递数据
        System.out.println("SelectUserServlet....");
        // 1.接收 URL http://ip:port/userdemo/selectUserServlet?username=zhangsan
        String username = req.getParameter("username");
        // 2.调用逻辑 (目前不去连接数据库，假设重名了
        // isFlag代表重名了
        boolean isFlag = true;
        // 3.返回,返回字符串
        resp.getWriter().write(""+isFlag);
    }
}
